# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-bluepy
_pkgname=bluepy
pkgver=1.3.0
pkgrel=3
pkgdesc='Python module for interfacing with BLE devices through Bluez.'
url='https://pypi.org/project/bluepy/#files'
arch=('any')
license=('GPL')
depends=('python2' 'bluez' 'glib2')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('1f06f8b1db869e9f74a965fab7d9cf6d42765012d2a88eb2b615a87a4e7721fbf0d9907619d1e80bb087188cd84b7e3f11f773480fe83c48fdfdfefb96cf5cd8')

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
  install -Dm 755 bluepy/bluepy-helper -t \
    "$pkgdir/usr/lib/python2.7/site-packages/$_pkgname"

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

